package com.sgb.kjwl.view.ui.fragment.home;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.util.Pair;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.androidkun.xtablayout.XTabLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener;
import com.sgb.kjwl.AppLazyFragment;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.FragmentEnterpriseManageBinding;
import com.sgb.kjwl.di.home.DaggerHomeFragComponent;
import com.sgb.kjwl.di.home.HomeFragModule;
import com.sgb.kjwl.interfaces.RecyclerClick;
import com.sgb.kjwl.model.ZulinMenuEntity;
import com.sgb.kjwl.model.entity.TwoLevelChildForPopWindowEntity;
import com.sgb.kjwl.model.entity.TwoLevelForPopWindowEntity;
import com.sgb.kjwl.model.entity.enterprise.IpPickSelectEntity;
import com.sgb.kjwl.model.entity.manage.TheEnterpriseOfAndVideoEntity;
import com.sgb.kjwl.model.entity.transport.SingleItemConstant;
import com.sgb.kjwl.model.entity.user.AddressEntity;
import com.sgb.kjwl.utils.ActivityJump;
import com.sgb.kjwl.utils.DialogFunction;
import com.sgb.kjwl.utils.DialogHelper;
import com.sgb.kjwl.view.ui.activity.enterprise.MakeOverActivity;
import com.sgb.kjwl.view.ui.activity.enterprise.NeedActivity;
import com.sgb.kjwl.view.ui.activity.enterprise.ProfessionalQuoteActivity;
import com.sgb.kjwl.view.ui.activity.leaseAsk.AskLeaseActivity;
import com.sgb.kjwl.view.ui.activity.lookingforAJob.FindWorksActivity;
import com.sgb.kjwl.view.ui.activity.manage.CompanyTradesActivity;
import com.sgb.kjwl.view.ui.activity.manage.EnterpriseAndMapActivity;
import com.sgb.kjwl.view.ui.activity.manage.EnterpriseAndMapActivity3;
import com.sgb.kjwl.view.ui.activity.manage.EpAssestActivity;
import com.sgb.kjwl.view.ui.activity.manage.IPActivity;
import com.sgb.kjwl.view.ui.activity.manage.ManageActivity;
import com.sgb.kjwl.view.ui.activity.manage.SpecialQualificationActivity;
import com.sgb.kjwl.view.ui.activity.manage.TradeHonorActivity;
import com.sgb.kjwl.view.ui.activity.manage.WebsiteInfoActivity;
import com.sgb.kjwl.view.ui.activity.pick.PickHallActivity3;
import com.sgb.kjwl.view.ui.activity.self.userInfo.VerificationCodeLoginActivity;
import com.sgb.kjwl.view.ui.activity.transport.GoodsCarsActivity;
import com.sgb.kjwl.view.ui.adapter.home.ZulinMenuAdapter;
import com.sgb.kjwl.view.ui.adapter.manage.ManageHallAdapter;
import com.sgb.kjwl.view.widget.EnterprisePopWindow;
import com.sgb.kjwl.view.widget.IpPopWindow;
import com.sgb.kjwl.view.widget.ThreeLevelAreaWindow;
import com.sgb.kjwl.view.widget.TwoLevelEntityPopWindow;
import com.sgb.kjwl.viewmodel.manage.EnterpriseManageFragModel;
import com.sgb.knowledgeshare.view.activity.PlayListActivity;
import com.sgb.link.event.MaterialEvent;
import com.swgk.core.base.di.AppComponent;
import com.swgk.core.event.EventConstant;
import com.swgk.core.event.MenuEvent;
import com.swgk.core.recyclerview.entity.BaseAreaEntity;
import com.swgk.core.refresh.SuperSwipeRefreshLayout;
import com.swgk.core.util.ClickUtils;
import com.swgk.core.util.MLog;
import com.swgk.core.util.PickSelectEntity;
import com.swgk.core.util.SharedPreferenceUtil;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.jetbrains.annotations.NotNull;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.inject.Inject;


/**
 * 首页-企业经营
 */
public class EnterpriseManageFragment extends AppLazyFragment implements SuperSwipeRefreshLayout.OnPullRefreshListener {
    @Inject
    public EnterpriseManageFragModel mModel;
    private FragmentEnterpriseManageBinding mBind;

    private ArrayList<Fragment> mFragments;
    private boolean mIsRefresh;
    private int mCurIndex;

    private TextView textView;
    private String longitude;//经度
    private String latitude;//纬度

    Map<String, Object> map = new HashMap<>();
    private ManageHallAdapter recommendedEnterprisesAdapter;

    private TwoLevelEntityPopWindow<TwoLevelForPopWindowEntity> mTwoLevelCategory;

    List<PickSelectEntity<List<PickSelectEntity>>> tradeCategoryDatas;//行业分类
    List<IpPickSelectEntity> tradeCategoryDatasForPop;//行业分类窗口展示
    private IpPopWindow tradeTypeWindow;

    private List<AddressEntity<List<AddressEntity<List<AddressEntity>>>>> provinceData = new ArrayList<>();//省数据
    private ThreeLevelAreaWindow cityPopWindow;//省市弹窗
    private EnterprisePopWindow distanceWindow;//距离弹窗
    private EnterprisePopWindow countWindow;//人数弹窗
    private List<PickSelectEntity> distanceData = new ArrayList<>();//距离数据
    private List<PickSelectEntity> countData = new ArrayList<>();//人数数据
    //省
    private String provinceNo = "";
    //地区
    private String citysNo = "";

    private String mTypeNo = "";
    private String mTypeSecondNo = "";
    //距离
    private String dic = "";

    private String name1 = "";
    private String name2 = "";
    private String name3 = "";
    private String mTypeName = "";

    public static EnterpriseManageFragment newInstance() {
        EnterpriseManageFragment fragment = new EnterpriseManageFragment();
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mBind = DataBindingUtil.inflate(inflater, R.layout.fragment_enterprise_manage, container, false);
        return mBind.getRoot();
    }

    @Override
    protected void setupFragmentComponent(AppComponent appComponent) {
        DaggerHomeFragComponent.builder()
                .appComponent(appComponent)
                .homeFragModule(new HomeFragModule(this))
                .build()
                .inject(this);
    }

    @Override
    protected void initView() {

        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }

        mBind.setViewModel(mModel);
        mModel.getRecommendedList(false, map);

        mBind.swipeRefresh.setOnPullRefreshListener(this);
        mBind.swipeRefresh.setHeaderView(createHeaderView());
        mBind.appBarLayout.addOnOffsetChangedListener((appBarLayout, i) -> mBind.swipeRefresh.setEnabled(i >= 0));
        mBind.srlFindCarByMap.setEnableRefresh(false);//禁止启用下拉刷新，默认是ture
        mBind.srlFindCarByMap.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull @NotNull RefreshLayout refreshLayout) {
                mModel.getRecommendedList(true, map);
            }

            @Override
            public void onRefresh(@NonNull @NotNull RefreshLayout refreshLayout) {

            }
        });
        mBind.ivShowMore.setOnClickListener(this);
        mBind.tvPlace.setOnClickListener(this);
        mBind.tvDistance.setOnClickListener(this);
        mBind.tvPeopleCount.setOnClickListener(this);
        mBind.tvType.setOnClickListener(this);
        initMenuView();
        initAdapter();
        initWindow();
        initTablayout();

    }

    private void initMenuView() {
        mModel.menuLD.observe(this, this::showMenu);
    }

    private void showMenu(List<List<ZulinMenuEntity>> data) {
        mBind.swipeRefresh.setRefreshing(false);
        ZulinMenuAdapter adapter = new ZulinMenuAdapter(getActivity(), data);//共有租赁的适配器
        adapter.setListener(entity -> jumptToAct(entity));
        mBind.recyclerMenu.setAdapter(adapter);
    }

    private void initAdapter() {
        if (recommendedEnterprisesAdapter == null) {
            recommendedEnterprisesAdapter = new ManageHallAdapter(null);
            recommendedEnterprisesAdapter.setmRecyclerClick(new RecyclerClick<TheEnterpriseOfAndVideoEntity>() {
                @Override
                public void followClick(TheEnterpriseOfAndVideoEntity entity) {
                    if (DialogHelper.checkLogin()) {
                        if (entity.getFollow()) {
                            DialogHelper.showDialog(getContext(), "提示", "确定取消关注该企业？", "取消关注", new DialogFunction() {
                                @Override
                                public void normalRoundDialog() {
                                    mModel.follow(entity.getSupplier());
                                }
                            });
                        } else {
                            mModel.follow(entity.getSupplier());
                        }
                    } else {
                        VerificationCodeLoginActivity.start(getContext(), EventConstant.EVENT_MANAGE);
                    }
                }
            });

            recommendedEnterprisesAdapter.setOnItemClickListener((adapter, view, position) -> {
                TheEnterpriseOfAndVideoEntity entity = recommendedEnterprisesAdapter.getData().get(position);
                if (entity.getItemType() == SingleItemConstant.TYPE_ONE) {
                    if (!TextUtils.isEmpty(entity.getSupplier())) {
                        WebsiteInfoActivity.start(getContext(), entity.getSupplier(), 1);
                    } else {
                        Toast.makeText(getActivity(), "公司no为空", Toast.LENGTH_SHORT).show();
                    }
                } else {
                    Intent intent = new Intent(getActivity(), PlayListActivity.class);
                    intent.putExtra(PlayListActivity.VIDEOLISTBEAN, (Serializable) entity.getList());
                    intent.putExtra(PlayListActivity.PSO, 0);
                    intent.putExtra(PlayListActivity.VIDEOTYPE, "goods_and_car_video");
                    startActivity(intent);
                }
            });
        }
        LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
        mBind.recyclerView.setLayoutManager(layoutManager);
        mBind.recyclerView.setAdapter(recommendedEnterprisesAdapter);
    }

    /**
     * 初始化筛选窗口
     */
    private void initWindow() {
        mTwoLevelCategory = new TwoLevelEntityPopWindow<>(getActivity());
        mTwoLevelCategory.setmTwoLevelClick(new TwoLevelEntityPopWindow.TwoLevelClick<TwoLevelForPopWindowEntity>() {
            @Override
            public void oneClick(TwoLevelChildForPopWindowEntity<List<TwoLevelForPopWindowEntity>> d, int position) {
                mTypeName = d.getName();
                if (!mTypeNo.equals(d.getNo())) {
                    mTypeSecondNo = "";
                    map.put("industryCategory2", mTypeSecondNo);
                }
                mTypeNo = d.getId();
                map.put("industryCategory1", mTypeNo);
            }

            @Override
            public void twoClick(TwoLevelForPopWindowEntity twoLevelEntityForPopWindow, int position) {
                mTypeName = twoLevelEntityForPopWindow.getName();
                mTypeSecondNo = twoLevelEntityForPopWindow.getId();
                map.put("industryCategory2", mTypeSecondNo);
            }

            @Override
            public void reset() {
                mTwoLevelCategory.dismiss();
                mModel.getRecommendedList(false, map);
            }
        });
        mTwoLevelCategory.setBgView(mBind.grayLayout);
        mTwoLevelCategory.setOnResultClick((key1, key2, key3) -> mModel.getRecommendedList(false, map));
        mTwoLevelCategory.setOnDismissListener(() -> mBind.tvType.contentSelect(!mTypeName.equals("") && !mTypeName.equals("不限"), false));

        //行业分类
        tradeTypeWindow = new IpPopWindow(getActivity());
        tradeTypeWindow.setBgView(mBind.grayLayout);
        tradeTypeWindow.setOnResultClick((type, key2, key3) -> mBind.tablayoutTop.getTabAt((int) key2).select());
        tradeTypeWindow.setOnDismissListener(() -> mBind.ivShowMore.setImageResource(R.mipmap.btn_expand1));

        // 省 城市
        cityPopWindow = new ThreeLevelAreaWindow(getActivity()) {
            @Override
            protected void provinceClick(BaseAreaEntity baseAreaEntity, int position) {
                super.provinceClick(baseAreaEntity, position);
                if (!provinceNo.equals(baseAreaEntity.getId())) {
                    citysNo = "";
                    map.put("areaNo", citysNo);
                }

                name1 = baseAreaEntity.getSimpleName();
                provinceNo = baseAreaEntity.getId();

                map.put("provinceNo", provinceNo);
            }

            @Override
            protected void cityClick(BaseAreaEntity baseAreaEntity, int position) {
                super.cityClick(baseAreaEntity, position);
                citysNo = baseAreaEntity.getId();

                name1 = baseAreaEntity.getSimpleName();
                map.put("areaNo", citysNo);
            }

            @Override
            protected void reset() {
                super.reset();
                cityPopWindow.dismiss();
                mModel.getRecommendedList(false, map);
            }
        };
        cityPopWindow.setBgView(mBind.grayLayout);
        cityPopWindow.setThreeListIsGone(true);
        cityPopWindow.setCitySingle();
        cityPopWindow.setProvinceSingle();
        cityPopWindow.setOnResultClick((key1, key2, key3) -> mModel.getRecommendedList(false, map));
        cityPopWindow.setOnDismissListener(() -> {
            mBind.tvPlace.contentSelect(!name1.equals("") && (!name1.equals("不限")), false);
            if (provinceNo.equals("")) {
                mBind.tvPlace.contentSelect(false, false);
            }
        });

//        距离
        distanceWindow = new EnterprisePopWindow(getActivity());
        distanceWindow.setBgView(mBind.grayLayout);
        distanceWindow.setOnResultClick((key1, key2, key3) -> {
            try {
                if ((key1).equals("")) {
                    dic = "";
                } else {
                    dic = Long.valueOf((String) key1) * 1000 + "";
                }
                name2 = (String) key2;
                //请求接口
                map.put("distance", dic);
                mModel.getRecommendedList(false, map);
            } catch (Exception e) {
                Toast.makeText(getActivity(), "您输入的数字太大", Toast.LENGTH_SHORT).show();
            }
        });
        distanceWindow.setOnDisMissClick(() -> mBind.tvDistance.contentSelect(!name2.equals("") && !name2.equals("不限"), false));

        //人数
        countWindow = new EnterprisePopWindow(getActivity());
        countWindow.setBgView(mBind.grayLayout);
        countWindow.setOnResultClick((key1, key2, key3) -> {
            name3 = (String) key2;
            //请求接口
            map.put("staffNumber", key1);
            mModel.getRecommendedList(false, map);

        });
        countWindow.setOnDisMissClick(() -> mBind.tvPeopleCount.contentSelect(!name3.equals("") && !name3.equals("不限"), false));
    }

    private void initTablayout() {
        mBind.tablayoutTop.setOnTabSelectedListener(new XTabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(XTabLayout.Tab tab) {
                int position = tab.getPosition();
                tradeTypeWindow.setDefItem(position);
                map.remove("category");
                mBind.tablayout1.setVisibility(View.GONE);
                mBind.tablayout2.setVisibility(View.GONE);
                map.put("serviceType", tradeCategoryDatas.get(position).getNo());
                mModel.getRecommendedList(false, map);
            }

            @Override
            public void onTabUnselected(XTabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(XTabLayout.Tab tab) {

            }
        });
    }


    @Override
    protected void onLazyLoad() {
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }
        //2021.3.18 通过数据库取经纬度值获取  不再企业经营首页监听定位
        longitude = SharedPreferenceUtil.getInstance().getString(SharedPreferenceUtil.LONGITUDE_ID, "");
        latitude = SharedPreferenceUtil.getInstance().getString(SharedPreferenceUtil.LATITUDE_ID, "");
        map.put("longitude", longitude);
        map.put("latitude", latitude);
        mModel.getMenuData();
        mModel.getTradeTypes();
        mModel.getTypeList();
        mModel.getCityData();
    }

    private void jumptToAct(ZulinMenuEntity entity) {
        switch (entity.getName()) {
            case "企业查询":
                EnterpriseAndMapActivity.start(getActivity(), longitude, latitude, false);
                break;
            case "地图查找":
                EnterpriseAndMapActivity3.start(getActivity());
                break;
            case "专项资质":
                SpecialQualificationActivity.startAction(getActivity());
                break;
            case "知识产权":
                IPActivity.startAction(getActivity());
                break;
            case "专项资产":
                EpAssestActivity.start(getActivity());
                break;
            case "荣誉荣耀":
                TradeHonorActivity.start(getActivity());
                break;
            case "经营动态":
                ActivityJump.jumpToActivity(getActivity(), CompanyTradesActivity.class);
                break;
            case "租赁需求":
                AskLeaseActivity.start(getActivity());
                break;
            case "劳务需求":
                FindWorksActivity.start(getActivity());
                break;
            case "物流需求":
                GoodsCarsActivity.start(getActivity());
                break;
            case "企服需求":
                NeedActivity.start(getActivity());
                break;
            case "企业招采":
                PickHallActivity3.start(getActivity());
                break;
            case "企业转让":
                ActivityJump.jumpToActivity(getActivity(), MakeOverActivity.class);
                break;
            case "企业服务":
                ActivityJump.jumpToActivity(getActivity(), ProfessionalQuoteActivity.class);
                break;
            case "经营大厅":
                ActivityJump.jumpToActivity(getActivity(), ManageActivity.class, Pair.create("latitude", latitude), Pair.create("longitude", longitude));
                break;
        }
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_type:
                mBind.tvType.contentSelect(false, true);
                mBind.appBarLayout.setExpanded(false);
                new Handler().postDelayed(this::showType, 300);
                break;
            case R.id.iv_show_more:
                if (!ClickUtils.isDoubleClick()) {
                    if (tradeCategoryDatas != null) {
                        tradeCategoryDatasForPop = new ArrayList<>();
                        IpPickSelectEntity entity;
                        for (PickSelectEntity pickSelectEntity : tradeCategoryDatas) {
                            entity = new IpPickSelectEntity();
                            entity.setValue(pickSelectEntity.getNo());
                            entity.setName(pickSelectEntity.getProjectscale());
                            tradeCategoryDatasForPop.add(entity);
                        }
                        showTradeTypePopWindow2(tradeCategoryDatasForPop);
                    }
                }
                break;
            case R.id.tv_place:
                if (!ClickUtils.isDoubleClick()) {
                    mBind.tvPlace.contentSelect(false, true);
                    if (provinceData.size() == 0) {
                        mModel.getCityData();
                    } else {
                        mBind.appBarLayout.setExpanded(false);
                        new Handler().postDelayed(this::showProvincePopWindow, 300);
                    }
                }
                break;
            case R.id.tv_distance:
                if (!ClickUtils.isDoubleClick()) {
                    mBind.tvDistance.contentSelect(false, true);
                    if (distanceData.size() == 0) {
                        mModel.getDistanceDatas();
                    } else {
                        showDistancePopWindow();
                    }
                }
                break;
            case R.id.tv_people_count:
                if (!ClickUtils.isDoubleClick()) {
                    mBind.tvPeopleCount.contentSelect(false, true);
                    if (countData.size() == 0) {
                        mModel.getCount();
                    } else {
                        showCountPopWindow();
                    }
                }
                break;

        }
    }

    private void refreshView() {
        mIsRefresh = true;
        if (mFragments == null || mFragments.size() == 0) {
            hideRefresh();
            onLazyLoad();
            return;
        }
        hideRefresh();
        Fragment fragment = mFragments.get(mCurIndex);
        if (fragment instanceof EnterpriseManageChildFragment) {
            ((EnterpriseManageChildFragment) fragment).init();
        }
    }

    public void hideRefresh() {
        mBind.swipeRefresh.setRefreshing(false);
    }

    public void setTablayout(List<PickSelectEntity<List<PickSelectEntity>>> datas) {
        tradeCategoryDatas = datas;
        mBind.tablayoutTop.removeAllTabs();
        for (int i = 0; i < datas.size(); i++) {
            mBind.tablayoutTop.addTab(mBind.tablayoutTop.newTab().setText(datas.get(i).getProjectscale()));
        }
        mBind.tablayoutTop.postDelayed(() -> mBind.tablayoutTop.setScrollPosition(0, 0, true), 100);
    }


    public void showList(List<TheEnterpriseOfAndVideoEntity> list, boolean isLoadMore) {
        if (mIsRefresh) {
            mIsRefresh = false;
        }
        mBind.srlFindCarByMap.finishLoadMore();
        if (isLoadMore) {
            if (null != list && list.size() > 0) {
//                mBind.recyclerView.loadMoreComplete();
                recommendedEnterprisesAdapter.addData(list);
            } else {
//                mBind.recyclerView.setNoMore(true);
            }
            mBind.srlFindCarByMap.setVisibility(View.VISIBLE);
        } else {
            if (null != list && list.size() > 0) {
                mBind.srlFindCarByMap.setVisibility(View.VISIBLE);
                mBind.emptyView.setVisibility(View.GONE);
                recommendedEnterprisesAdapter.setNewData(list);
//                mBind.recyclerView.setLoadingMoreEnabled(true);
            } else {
                recommendedEnterprisesAdapter.setNewData(null);
                mBind.srlFindCarByMap.setVisibility(View.GONE);
                mBind.emptyView.setVisibility(View.VISIBLE);
            }
        }
    }


    private View createHeaderView() {
        @SuppressLint("InflateParams")
        View headerView = LayoutInflater.from(mBind.swipeRefresh.getContext()).inflate(R.layout.super_swipe_refresh_head, null);
        ProgressBar progressBar = headerView.findViewById(R.id.pb_view);
        textView = headerView.findViewById(R.id.text_view);
        textView.setText("下拉刷新");
        progressBar.setVisibility(View.GONE);
        return headerView;
    }

    @Override
    public void onRefresh() {
        textView.setText("正在刷新");
        refreshView();
    }

    @Override
    public void onPullDistance(int distance) {

    }

    @Override
    public void onPullEnable(boolean enable) {
        textView.setText(enable ? "释放立即刷新" : "下拉刷新");
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEvent(MenuEvent event) {
        if (event.getMessageTag() == EventConstant.EVENT_MENU_POWER) {
            MLog.d("api", event.getNo());
        }
    }

    @Override
    public void onDestroy() {
        EventBus.getDefault().unregister(this);
        super.onDestroy();
    }


    //行业分类
    public void showTradeTypePopWindow2(List<IpPickSelectEntity> datas) {
        tradeTypeWindow.setData(datas);
        tradeTypeWindow.showPopwindow(mBind.tabLayout, 0, 0);
        mBind.ivShowMore.setImageResource(R.mipmap.btn_expand_up_gray);
    }


    private void showProvincePopWindow() {
        cityPopWindow.showPopwindow(mBind.roomLayout, 0, 0);
    }

    public void setCityData(List<AddressEntity<List<AddressEntity<List<AddressEntity>>>>> datas, String areaCode) {
        provinceData = datas;
        cityPopWindow.setDataForCompany(datas, true);
    }

    private void showDistancePopWindow() {
        distanceWindow.showPopwindow(mBind.roomLayout, 0, 0);
    }

    //设置距离数据
    public void setDistanceDatas(List<PickSelectEntity> datas) {
        distanceData.clear();
        distanceData.addAll(datas);
        distanceWindow.setData(distanceData, true, false);
        distanceWindow.showPopwindow(mBind.roomLayout, 0, 0);
    }

    private void showCountPopWindow() {
        countWindow.showPopwindow(mBind.roomLayout, 0, 0);
    }

    //设置人数数据
    public void setCountDatas(List<PickSelectEntity> datas) {
        countData.clear();
        countData.addAll(datas);
        countWindow.setData(countData);
        countWindow.showPopwindow(mBind.roomLayout, 0, 0);
    }

    public void setType(List<TwoLevelChildForPopWindowEntity<List<TwoLevelForPopWindowEntity>>> data) {
        mTwoLevelCategory.setData(data);
    }

    private void showType() {
        mTwoLevelCategory.showPopwindow(mBind.roomLayout, 0, 0);
    }

    public void followSuccess() {
        mModel.getRecommendedList(false, map);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventBus(MaterialEvent event) {
        if (event.getMessageTag() == EventConstant.EVENT_MANAGE) {
            mModel.getRecommendedList(false, map);
        }
    }
}
